import Taro, { Component, Config } from '@tarojs/taro';
import Main from './components/Main';

export default class Index extends Component {
  componentWillMount() {}

  componentDidMount() {
    // const query = Taro.createSelectorQuery();
    // query
    //   .select('#canvas')
    //   .fields({ node: true, size: true })
    //   .exec((res) => {
    //     const canvas: HTMLCanvasElement = res[0].node;
    //     console.log({ res, canvas });
    //     this.canvasContext = canvas.getContext('2d');
    //     // const dpr = Taro.getSystemInfoSync().pixelRatio;
    //     // canvas.width = res[0].width * dpr;
    //     // canvas.height = res[0].height * dpr;
    //     // this.canvasContext && this.canvasContext.scale(dpr, dpr);
    //   });
    // this.canvasContext = Taro.createCanvasContext('myCanvas');
  }

  componentWillUnmount() {}

  componentDidShow() {}

  componentDidHide() {}

  /**
   * 指定config的类型声明为: Taro.Config
   *
   * 由于 typescript 对于 object 类型推导只能推出 Key 的基本类型
   * 对于像 navigationBarTextStyle: 'black' 这样的推导出的类型是 string
   * 提示和声明 navigationBarTextStyle: 'black' | 'white' 类型冲突, 需要显示声明类型
   */
  config: Config = {
    navigationBarTitleText: '王者大师',
  };

  // canvasContext: Taro.CanvasContext | null = null;
  context: Taro.CameraContext | null = null;

  render() {
    return <Main />;
  }
}
